import json
import decimal
from datetime import date, datetime


class JsonCustomEncoder(json.JSONEncoder):
    def default(self, field):
        if isinstance(field, datetime):
            return field.strftime('%Y-%m-%d %H:%M:%S')
        elif isinstance(field, date):
            return field.strftime('%Y-%m-%d')
        elif isinstance(field, decimal.Decimal):
            return str(decimal.Decimal(field).quantize(decimal.Decimal('0.00')))
        else:
            return json.JSONEncoder.default(self, field)
